<template>
  <common-page
    ref="commonPage"
    :bg-path="bgPath"
    :web-path="webPath"
    :columns="columns"
    :search-items="searchItems"
    :form-items="formItems"
  />
</template>
<script>
export default {
  data() {
    return {
      // ===== ===== ===== ===== 全局属性 ===== ===== ===== =====
      // 后台接口路径
      bgPath: 'clinic/supplier/supplier/suppliermateriel',
      // Web路径
      webPath: 'clinic/Supplier/Supplier/SupplierMateriel',
      // ===== ===== ===== ===== 页面配置 ===== ===== ===== =====
      // 搜索内容
      searchItems: [
        {
          rowIndex: 1,
          items: [
            {
              code: "code",
              name: "编码",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            },
            {
              code: "name",
              name: "名称",
              type: "text",
              span: 6,
              config: {
                edit: false
              }
            },
            {
              code: "materielCode",
              name: "物料编码",
              type: "text",
              span: 6,
              config: {
                edit: false
              }
            },
            {
              code: "materielName",
              name: "物料名称",
              type: "text",
              span: 6,
              config: {
                edit: false
              }
            }
          ]
        }
      ],
      // 列表内容
      columns: [
        {
          code: "code",
          name: "编码",
          span: 6,
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "name",
          name: "名称",
          type: "text",
          span: 6,
          config: {
            edit: false
          }
        },
        {
          code: "iotCode",
          name: "条码",
          type: "text",
          span: 6,
          config: {
            edit: false
          }
        },
        {
          code: "materielCode",
          name: "物料编码",
          type: "text",
          span: 6,
          config: {
            edit: false
          }
        },
        {
          code: "materielName",
          name: "物料名称",
          type: "text",
          span: 6,
          config: {
            edit: false
          }
        },
        {
          code: "unitPrice",
          name: "条码",
          type: "number",
          span: 6,
          config: {
            edit: false,
            precision: 2
          }
        },
        {
          code: "materielTypeSign",
          name: "物料类型标识",
          type: "select",
          span: 6,
          config: {
            edit: false,
            options: [
              { key: "1", value: "中成药" },
              { key: "2", value: "西药" },
              { key: "3", value: "饮片" },
              { key: "4", value: "服务" },
              { key: "5", value: "产品" }
            ]
          }
        }, {
          code: "materielTypeCode",
          name: "物料类型编码",
          type: "text",
          span: 6,
          config: {
            edit: false
          }
        }, {
          code: "materielTypeName",
          name: "物料类型名称",
          type: "text",
          span: 6,
          config: {
            edit: false
          }
        }, {
          code: "materielIotCode",
          name: "条码",
          type: "text",
          span: 6,
          config: {
            edit: false
          }
        }, {
          code: "materielInsuranceCode",
          name: "医保码",
          type: "text",
          span: 6,
          config: {
            edit: false
          }
        }, {
          code: "medUomCode",
          name: "药品单位编码",
          type: "text",
          span: 6,
          config: {
            edit: false
          }
        }, {
          code: "medUomName",
          name: "药品单位名称",
          type: "text",
          span: 6,
          config: {
            edit: false
          }
        }, {
          code: "medSpecCode",
          name: "药品规格编码",
          type: "text",
          span: 6,
          config: {
            edit: false
          }
        }, {
          code: "medSpecName",
          name: "药品规格名称",
          type: "text",
          span: 6,
          config: {
            edit: false
          }
        }, {
          code: "medDosageCode",
          name: "药品剂型编码",
          type: "text",
          span: 6,
          config: {
            edit: false
          }
        }, {
          code: "medDosageName",
          name: "药品剂型名称",
          type: "text",
          span: 6,
          config: {
            edit: false
          }
        }, {
          code: "meaUomCode",
          name: "计量单位编码",
          type: "text",
          span: 6,
          config: {
            edit: false
          }
        }, {
          code: "meaUomName",
          name: "计量单位名称",
          type: "text",
          span: 6,
          config: {
            edit: false
          }
        }, {
          code: "classifyUomCode",
          name: "物料分类编码",
          type: "text",
          span: 6,
          config: {
            edit: false
          }
        }, {
          code: "classifyUomName",
          name: "物料分类名称",
          type: "text",
          span: 6,
          config: {
            edit: false
          }
        }
      ],
      // 增加/修改/详情 表单
      formItems: [
        {
          rowIndex: 1,
          items: [
            {
              code: "code",
              name: "编码",
              span: 6,
              type: "text",
              config: {
                edit: false,
                require: true
              }
            },
            {
              code: "name",
              name: "名称",
              type: "text",
              span: 6,
              config: {
                edit: false,
                require: true
              }
            },
            {
              code: "iotCode",
              name: "条码",
              type: "text",
              span: 6,
              config: {
                edit: false
              }
            },
            {
              code: "materielCode",
              span: 6,
              name: "物料编码",
              type: "popup",
              config: {
                url: "base/dictionary/medicinedic/materiel",
                filedList: [
                  { code: 'code', name: '编码' },
                  { code: 'name', name: '名称' }
                ],
                searcher: {},
                defaultValue: "",
                minLength: 0,
                maxLength: 20,
                disabled: false,
                require: true
              },
              handleEvent: {
                /**
                 * 开窗组件被选择
                 * @param code
                 * @param row
                 */
                onPopupClick: (code, row) => {
                  console.log("row", row)
                  const formData = {
                    materielName: row.name,
                    materielCode: row.code,
                    materielId: row.id

                  }
                  this.$refs.commonPage.updateFormData(formData)
                }
              }
            },
            {
              code: "materielName",
              name: "物料名称",
              type: "text",
              span: 6,
              config: {
                edit: false,
                disabled: true
              }
            },
            {
              code: "unitPrice",
              name: "销售定价",
              type: "number",
              span: 6,
              config: {
                edit: false,
                precision: 2,
                disabled: true
              }
            },
            {
              code: "materielTypeSign",
              name: "物料类型标识",
              type: "select",
              span: 6,
              config: {
                edit: false,
                options: [
                  { key: "1", value: "中成药" },
                  { key: "2", value: "西药" },
                  { key: "3", value: "饮片" },
                  { key: "4", value: "服务" },
                  { key: "5", value: "产品" }
                ],
                disabled: true
              }
            }, {
              code: "materielTypeCode",
              name: "物料类型编码",
              type: "text",
              span: 6,
              config: {
                edit: false,
                disabled: true
              }
            }, {
              code: "materielTypeName",
              name: "物料类型名称",
              type: "text",
              span: 6,
              config: {
                edit: false,
                disabled: true
              }
            }, {
              code: "materielIotCode",
              name: "条码",
              type: "text",
              span: 6,
              config: {
                edit: false,
                disabled: true
              }
            }, {
              code: "materielInsuranceCode",
              name: "医保码",
              type: "text",
              span: 6,
              config: {
                edit: false,
                disabled: true
              }
            }, {
              code: "medUomCode",
              name: "药品单位编码",
              type: "text",
              span: 6,
              config: {
                edit: false,
                disabled: true
              }
            }, {
              code: "medUomName",
              name: "药品单位名称",
              type: "text",
              span: 6,
              config: {
                edit: false,
                disabled: true
              }
            }, {
              code: "medSpecCode",
              name: "药品规格编码",
              type: "text",
              span: 6,
              config: {
                edit: false,
                disabled: true
              }
            }, {
              code: "medSpecName",
              name: "药品规格名称",
              type: "text",
              span: 6,
              config: {
                edit: false,
                disabled: true
              }
            }, {
              code: "medDosageCode",
              name: "药品剂型编码",
              type: "text",
              span: 6,
              config: {
                edit: false,
                disabled: true
              }
            }, {
              code: "medDosageName",
              name: "药品剂型名称",
              type: "text",
              span: 6,
              config: {
                edit: false,
                disabled: true
              }
            }, {
              code: "meaUomCode",
              name: "计量单位编码",
              type: "text",
              span: 6,
              config: {
                edit: false,
                disabled: true
              }
            }, {
              code: "meaUomName",
              name: "计量单位名称",
              type: "text",
              span: 6,
              config: {
                edit: false,
                disabled: true
              }
            }, {
              code: "classifyUomCode",
              name: "物料分类编码",
              type: "text",
              span: 6,
              config: {
                edit: false,
                disabled: true
              }
            }, {
              code: "classifyUomName",
              name: "物料分类名称",
              type: "text",
              span: 6,
              config: {
                edit: false,
                disabled: true
              }
            }
          ]
        }
      ]
    }
  }
}
</script>
